package com.znyj.servlet.sqlHelper;

/**
 * Created by nameless on 15-2-12.
 */
public class Where {

    public enum Judge {

        LT("<"), LE("<="), EQ("="), NOT_EQ("!="), NE("!="), BE(">="), BT(">"), LIKE(" LIKE "), NOT_LIKE(" NOT LIKE "), IN(" IN "), NOT_IN(" NOT IN "), CAST(" CAST ");
        private String value;

        Judge(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return this.value;
        }
    }

    public enum Conjunction {

        NULL(""),AND(" AND "), OR(" OR ");
        private String value;

        Conjunction(String value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return this.value;
        }
    }

    private Judge judge;
    private String fieldName;
    private Object value;
    private boolean ignore;
    private Conjunction conjunction; //前面的连接词  OR 或者 AND

    public Where() {
    }

    public Where(Judge judge, String fieldName, Object value) {
        this.judge = judge;
        this.fieldName = fieldName;
        this.value = value;
        this.ignore = false;
        this.conjunction = Conjunction.AND;
    }

    public Where(Judge judge, String fieldName, Object value,Conjunction conjunction) {
        this.judge = judge;
        this.fieldName = fieldName;
        this.value = value;
        this.ignore = false;
        this.conjunction = conjunction;
    }

    public Where(Judge judge, String fieldName, Object value, boolean ignore) {
        this.judge = judge;
        this.fieldName = fieldName;
        this.value = value;
        this.ignore = ignore;
        this.conjunction = Conjunction.AND;
    }

    public Judge getJudge() {
        return judge;
    }

    public void setJudge(Judge judge) {
        this.judge = judge;
    }

    public Conjunction getConjunction() {
        return conjunction;
    }

    public void setConjunction(Conjunction conjunction) {
        this.conjunction = conjunction;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public Object getValue() {
        return value;
    }

    public void setValue(Object value) {
        this.value = value;
    }

    public boolean isIgnore() {
        return ignore;
    }

    public void setIgnore(boolean ignore) {
        this.ignore = ignore;
    }
}
